<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.ionglobal.misc.*" %>

<%@ include file="../init_include.jsp" %>

<%
	Integer catId;
	int totalpages,pageid=0;
	int pagerows=Page.getPageRows();
	int totalrows=0;
  String ordermode="desc";
  String orderfield="id";
  		
	int check_rst=Permission.accept(dbi,session,request,"sysop","tree","catid","000000010"); 
	if (check_rst!=Permission.CHECK_RST_SUCCESS) {
		dbi.closeAll();
		if (check_rst==Permission.CHECK_RST_DENY)
			response.sendRedirect("../deny.html");
		else
			response.sendRedirect("../index.jsp");
		return;		
	}

	if(request.getParameter("ordermode")!=null)
		ordermode=request.getParameter("ordermode");	
	if(request.getParameter("orderfield")!=null)
		orderfield=request.getParameter("orderfield");	

	Sysop sysop=(Sysop)session.getAttribute("sysop");	
	int classid = 0;
	try {
		if (request.getParameter("id")!=null)
			classid=Integer.parseInt(request.getParameter("id"));
	}	catch(NumberFormatException e) {
		return ;
	}		
	
	String a=request.getParameter("catid");
	String str="";
	try {
		catId=Integer.valueOf(a);		
	}	catch(NumberFormatException e) {
		out.println(e+"catId");
		return;
	}
	
	try {
		if (request.getParameter("pageid")!=null)
			pageid=Integer.parseInt(request.getParameter("pageid"));
		else
			pageid=1;
	}	catch(NumberFormatException e) {
		out.println(e+"pageid");
		pageid=1;
	}	
	
	try {
		if (request.getParameter("pagerows")!=null)
			pagerows=Integer.parseInt(request.getParameter("pagerows"));
	} catch(NumberFormatException e) {
		out.println(e+"pagerows");
	}	

	totalrows=Classes.getClassesNum(dbi,classid);
	totalpages = (int)Math.ceil((double)totalrows/pagerows);
	if(pageid>totalpages)
		pageid=totalpages;
	if(pageid<=1)
		pageid=1;
%>	
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=<%=Language.getHTMLLanguageStr()%>">
<link rel="stylesheet" href="../css.css" type="text/css">
<SCRIPT language=JavaScript1.2 src="../script/Ion_Show.js"></SCRIPT>
<script language="javascript">
<!--
	function Ion_Del()
	{
		deleteIon('vmsSelectFrame.jsp','../sys/sys_class_delete.jsp','<%=Language.getNameByCode("sys.class","Group")%>');
	}

	function Ion_Edit()
	{
		editIon('vmsSelectFrame.jsp','../sys/sys_class_dj.jsp','<%=Language.getNameByCode("sys.class","Group")%>');
	}

	function Ion_Add()
	{
		add_Ion('vmsSelectFrame.jsp','../sys/sys_class_dj.jsp','classid');
	}
-->
</script>
</head>

<body bgColor=#d6d3ce leftMargin=0 
style="BORDER-BOTTOM: 0px outset; BORDER-LEFT: 0px outset; BORDER-RIGHT: 0px outset; BORDER-TOP: 0px outset" 
topMargin=0>

<FORM name="formIon" method="post" action="sys_class_list.jsp" onsubmit="">
<table width="100%" border="0" cellspacing="1" cellpadding="2">
  <tr>
    <td class="nagivation" colspan="2"><%=Language.getNameByCode("sys.CurrentPos","Current Position")%>:<% 
    Vector vcpath=Category.getLadder(session,"tree",(catId.intValue()));
		out.print(Category.getFullPath(vcpath));
		UserTreeManager tm = new UserTreeManager();
		tm.setSqlNode( "select id,name,parentid,layer from sys_class" );
		Vector aavc = tm.getAllAncestors( dbi, classid );
		boolean href = false;
		for( int i = 0; i < aavc.size(); i++ ){
			UserTreeNode node = (UserTreeNode)aavc.get(i);
			if( node.getParentId() == sysop.getId() || node.getId() == sysop.getId() )
				href= true;
			if( href ){
	%>
		-&gt; <a href="sys_class_list.jsp?catid=<%=catId%>&id=<%=node.getId()%>"><%=node.getName()%></a>
	<%
			} else {
	%>
		-&gt; <%=node.getName()%>
<%		}
		}
%>
		
		</td>
  </tr>
	<tr>
   	<td align="left">
   		<%=Language.getNameByCode("sys.class.list","Group List:")%><%=PageStr.getPageHead(totalrows,pageid,pagerows,totalpages)%>
   	</td>
   	<td align=right>
   		<%=PageStr.PageForm(pageid,totalpages)%><input type="submit" name="Submit" value="go" style="width:0">
    </td>
 	</tr>
</table>

	<TABLE border=0 cellPadding=0 cellSpacing=1 height="100%" width="100%">
		<input type="hidden" name="catid" value="<%=catId%>">
		<input type="hidden" name="id" value="<%=classid%>">
		<INPUT name="objid" type="hidden">
		<INPUT name="objtext" type="hidden">
		<INPUT name="actionurl" type="hidden">
		<input type="hidden" name="orderfield" value="<%=orderfield%>">
		<input type="hidden" name="ordermode" value="<%=ordermode%>">
  	<TR>
    <TD>
   <%
    
   Table table=new Table();
   table.setSortMode(ordermode);
   table.setSortField(orderfield);
   table.setSelectionMode("multiple");

   table.addColumn("no","id",0,"center","left","number");
   table.addColumn(Language.getNameByCode("sys.class.id","ID"),"id",30,"center","left","text");
   table.addColumn(Language.getNameByCode("sys.class.name","Name"),"name",100,"center","left","text");
   table.addColumn(Language.getNameByCode("sys.class.code","Code"),"code",80,"center","left","text");
   table.addColumn(Language.getNameByCode("sys.class.descript","Descript"),"descript",400,"center","left","text");

    ArrayList rowsList=new ArrayList();
    try {
     Vector vc=Classes.getClassess(dbi,classid,pageid,pagerows,orderfield,ordermode);
     String rowData="";
     for(int i=0;i<vc.size();i++) {
      Classes classes=(Classes)vc.get(i);
      rowData=classes.getId()+"|"+classes.getId()+"|"+classes.getName()+"|"+classes.getClassCode()+"|"+(classes.getDescript()+" ");
      rowsList.add(rowData);
     }
    } catch(Exception E) {
    }
    ArrayList menuList=new ArrayList();
    TableMenu tmenu=null;

    tmenu=new TableMenu(Language.getNameByCode("sys.class.Edit","Edit Selected Group"),"javascript:Ion_Edit();",false);
    menuList.add(tmenu);
    tmenu=new TableMenu(Language.getNameByCode("sys.class.Add","New Group"),"JavaScript:Ion_Add();",true);
    menuList.add(tmenu);
    tmenu=new TableMenu(Language.getNameByCode("sys.class.SeeChild","View Sub-Group"),"javascript:changeIon('sys_class_list.jsp','"+Language.getNameByCode("sys.class","Group")+"');",false);
    menuList.add(tmenu);    
    tmenu=new TableMenu(Language.getNameByCode("sys.class.SeeUser","View User in Group"),"javascript:changeIon('sys_class_user_list.jsp','"+Language.getNameByCode("sys.class","Group")+"');",true);
    menuList.add(tmenu);
    tmenu=new TableMenu(Language.getNameByCode("sys.Head.Refresh","Refresh"),"javascript:self.location.reload();",true);
    menuList.add(tmenu);
    tmenu=new TableMenu(Language.getNameByCode("sys.class.Delete","Delete Selected Group"),"javascript:Ion_Del();",false);
    menuList.add(tmenu);

    table.setTableMenu(menuList);
    table.setRowsList(rowsList);
    TableDB tdb=new TableDB();
    out.print(tdb.draw(table));
    %>
	</TD>
 	</TR>
</TABLE>
</FORM>
</body>
</html>
<%@ include file="../init_free.jsp" %>